package exception;

import enums.BaseErrorCode;

/**
 * @author kehong
 * Created by on  2021-06-22 14:23
 */
public class BusinessException extends RuntimeException {

    private static final long serialVersionUID = -446784802285331881L;
    private IErrorCode errorCode;

    public BusinessException(IErrorCode code, String message, Throwable cause) {
        super(message, cause);
        this.errorCode = BaseErrorCode.INTERNAL_SERVER_ERROR;
        this.errorCode = code;
    }

    public BusinessException(IErrorCode code, Throwable cause) {
        super(code.getMessage(), cause);
        this.errorCode = BaseErrorCode.INTERNAL_SERVER_ERROR;
        this.errorCode = code;
    }

    public BusinessException(IErrorCode code, String message) {
        super(message);
        this.errorCode = BaseErrorCode.INTERNAL_SERVER_ERROR;
        this.errorCode = code;
    }

    public BusinessException(IErrorCode code) {
        super(code.getMessage());
        this.errorCode = BaseErrorCode.INTERNAL_SERVER_ERROR;
        this.errorCode = code;
    }

    public BusinessException(String message) {
        super(message);
        this.errorCode = BaseErrorCode.INTERNAL_SERVER_ERROR;
    }

    public IErrorCode getErrorCode() {
        return this.errorCode;
    }
}
